|
|
|
| Table 13.1. continued | | SQL-VB5 Command | Example | Description | | dbClose | dbClose; | The dbClose command closes the Microsoft Jet database that was opened using the dbOpen or dbMake command. | | ; | SELECT * FROM Table1; | The semicolon is used to indicate the end of a command. Commands can stretch over several lines of text but each command must always end with a semicolon (;). |
|
|
|
|
|
|
You now have enough information about SQL-VB5 to use it in the rest of the lesson today. As you go through the examples, you learn more about SQL-VB5 and how you can create your own SQL scripts. If you want to know more about how SQL-VB5 works, see Appendix A. |
|
|
|
|
|
|
|
|
Why Use SQL to Create and Manage Data Tables? |
|
|
|
|
|
|
|
|
Before you jump into the details of SQL keywords, let's talk about the advantages of using SQL statements to create and manage your data tables. |
|
|
|
|
|
|
|
|
Although Visual Basic offers several powerful commands for performing the same functions within a Visual Basic program, you might find that using SQL keywords to perform database management gives you an advantage. By using SQL statements to create and maintain your database structures, you can easily create useful documentation on how your databases are structured. Are you trying to debug a problem at a client site and can't remember how the tables are laid out? If you used a set of SQL statements to create the tables, you can refer to that script when you are solving your client's problems. |
|
|
|
|
|
|
|
|
It is also easy to generate, test, or sample data tables using SQL statements. If you are working on a database design and are still experimenting with table layouts and relationships, you can quickly put together an SQL DDL script, run it through SQL-VB5, and review the results. If, after experimenting, you find you need a new field in a table, you can alter your existing script and rerun it. Or you can write a short script that makes only the changes you need, preserving any data you have loaded into the existing tables. |
|
|
|
|
|
|
|
|
You can even use SQL statements to load test data into your new tables. After you have created the tables, you can add SQL statements to your script that load test data into the columns. |
|
|
|
|
|